Hi,
pragma runLim,0
#include <utils/helpers.inc>
string logFilename = "D:\\xx.log"
Stream logfile = append(logFilename)
logfile << dateAndTime(today) " #start\n"
string targetFolder
bool hasExtLink = false
Buffer sourceURL = create
Object o
Object sourceObject
//*****************************************************************************************************************************
void findSourceObject(Link l) {
sourceObject = source (l)
sourceURL = getURL(sourceObject)
}
//*****************************************************************************************************************************
//*****************************************************************************************************************************
void processModule(string moduleName) {
m = edit(moduleName, false)
logfile << dateAndTime(today) " now processing module '" moduleName "'\n"
for o in entire m do {
sourceURL = ""
openSourceModules(o)
Link lnk
for lnk in o <- "*" do if (prefixCorrect(module source (lnk), "TRS")) if (moduleHasAttribute(module source (lnk), "xx")) findSourceObject(lnk)
//check if external link to sourceObject already exists
logfile << dateAndTime(today) " LS '" fullName(m) "' '" o."Absolute Number" "' linkString is '" tempStringOf(sourceURL) "'\n"
if (tempStringOf(sourceURL) != "") {
hasExtLink = false
ExternalLink el
for el in o -> "*" do hasExtLink = true
//if not: create external link to sourceObject
if (!hasExtLink) {
create(o, "sourceObject", "dailyUpdate.sourceLink", outward, openAsURL, tempStringOf(sourceURL), el)
logfile << dateAndTime(today) " L '" fullName(m) "' '" o."Absolute Number" "' Create ExtLink to '" sourceURL "'\n"
}//end if (!hasExtLink)
}//end if (tempStringOf(sourceURL) != "")
}//end for object in entire module
save (m)
close(m)
}
//*****************************************************************************************************************************
//*****************************************************************************************************************************
Item i
for i in folder targetFolder do if (type(i) == "Formal") processModule (fullName(i))
closeAllModules()
}// end read config
//*****************************************************************************************************************************
delete(sourceURL)
logfile << dateAndTime(today) " #stop dailyUpdate\n"
flush(logfile)
close(logfile)
ManuelFelger - Tue May 04 04:43:38 EDT 2010 |
Re: function 'getURL()' seems to work only once If you add parameter 'Object o' to function <findSourceObject(Object o, Link l)>, and inside issue a print ">>findSourceObject " (identifier(o) "\tURL <">\n" I think you will find that function findSourceObject isn't getting called very often, and the URL is null because you correctly set it to null in your loop. Maybe those other objects don't have many qualifying incoming links. On other news... You don't need sourceURL in a Buffer. Using a string variable doesn't add to the string table more than once, but manipulating does. You are only getting the URL for the last incoming link to an object o; seems to me you'd want an external link for all of ..err.. each of them. It appears I'm the only person who hates those run-on clauses: for bla in bla do if (bla) if (also bla) for bla in bla do bla Auto Declare in on, tsk tsk tsk. Look for 'AutoDeclareSet.dxl' to switch it on and off.
|